//
//  SingleH.m
//  ACE
//
//  Created by Mickey Yin on 2022/3/24.
//

#import "SingleH.h"

// 创建静态对象 防止外部访问
static SingleH *_singleInstance = nil;

@implementation SingleH

+ (instancetype)sharedInstance
{
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        _singleInstance = [[self alloc] init];
    });
    return _singleInstance;
}

//+ (instancetype)allocWithZone:(struct _NSZone *)zone
//{
//    static dispatch_once_t onceToken;
//    dispatch_once(&onceToken, ^{
//        _singleInstance = [super allocWithZone:zone];
//    });
//    return _singleInstance;
//}

- (id)copyWithZone:(NSZone *)zone
{
    return _singleInstance;
}

- (id)mutableCopyWithZone:(NSZone *)zone
{
    return _singleInstance;
}

//+ (instancetype)allocWithZone:(struct _NSZone *)zone{
//    static dispatch_once_t onceToken;
//    dispatch_once(&onceToken, ^{
//        _singleInstance = [super allocWithZone:zone ];
//    });
//    return _singleInstance;
//}
//
//+ (instancetype) sharedInstance {
//    if (_singleInstance == nil) {
//        _singleInstance = [[super alloc]init];
//    }
//    return _singleInstance;
//}
//
//- (id)copyWithZone:(NSZone *)zone {
//    return _singleInstance;
//}
//
//- (id)mutableCopyWithZone:(NSZone *)zone {
//    return _singleInstance;
//}

@end
